package com.zf.sqlite.utils;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface WhitelistDao {
    @Query("SELECT * FROM zfed_whitelist ORDER BY whitelist_add_time DESC")
    List<WhitelistEntity> getAllWhitelist();

    @Query("SELECT * FROM zfed_whitelist WHERE type = :type ORDER BY whitelist_add_time DESC")
    List<WhitelistEntity> getWhitelistByType(int type);

    @Query("SELECT * FROM zfed_whitelist WHERE device_mac = :mac")
    WhitelistEntity getWhitelistByMac(String mac);

    @Insert
    void insertWhitelist(WhitelistEntity whitelist);

    @Update
    void updateWhitelist(WhitelistEntity whitelist);

    @Delete
    void deleteWhitelist(WhitelistEntity whitelist);

    @Query("DELETE FROM zfed_whitelist WHERE id = :id")
    void deleteWhitelistById(long id);

    @Query("DELETE FROM zfed_whitelist")
    void deleteAllWhitelist();
}
